package com.diyiliu.common.map;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Generated;

import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * Created by lichao on 2016/12/17.
 */
@SuppressWarnings({ "cast", "rawtypes", "serial", "unchecked" })
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2016-12-12")
public class ILocationService {

    public interface Iface {

        public MapLocation getLocation(double lon, double lat)
                throws TException;

    }

    public interface AsyncIface {

        public void getLocation(double lon, double lat,
                                AsyncMethodCallback resultHandler) throws TException;

    }

    public static class Client extends org.apache.thrift.TServiceClient
            implements Iface {
        public static class Factory implements
                org.apache.thrift.TServiceClientFactory<Client> {
            public Factory() {
            }

            public Client getClient(org.apache.thrift.protocol.TProtocol prot) {
                return new Client(prot);
            }

            public Client getClient(org.apache.thrift.protocol.TProtocol iprot,
                                    org.apache.thrift.protocol.TProtocol oprot) {
                return new Client(iprot, oprot);
            }
        }

        public Client(org.apache.thrift.protocol.TProtocol prot) {
            super(prot, prot);
        }

        public Client(org.apache.thrift.protocol.TProtocol iprot,
                      org.apache.thrift.protocol.TProtocol oprot) {
            super(iprot, oprot);
        }

        public MapLocation getLocation(double lon, double lat)
                throws TException {
            send_getLocation(lon, lat);
            return recv_getLocation();
        }

        public void send_getLocation(double lon, double lat) throws TException {
            getLocation_args args = new getLocation_args();
            args.setLon(lon);
            args.setLat(lat);
            sendBase("getLocation", args);
        }

        public MapLocation recv_getLocation() throws TException {
            getLocation_result result = new getLocation_result();
            receiveBase(result, "getLocation");
            if (result.isSetSuccess()) {
                return result.success;
            }
            throw new org.apache.thrift.TApplicationException(
                    org.apache.thrift.TApplicationException.MISSING_RESULT,
                    "getLocation failed: unknown result");
        }

    }

    public static class AsyncClient extends
            org.apache.thrift.async.TAsyncClient implements AsyncIface {
        public static class Factory implements
                org.apache.thrift.async.TAsyncClientFactory<AsyncClient> {
            private org.apache.thrift.async.TAsyncClientManager clientManager;
            private org.apache.thrift.protocol.TProtocolFactory protocolFactory;

            public Factory(
                    org.apache.thrift.async.TAsyncClientManager clientManager,
                    org.apache.thrift.protocol.TProtocolFactory protocolFactory) {
                this.clientManager = clientManager;
                this.protocolFactory = protocolFactory;
            }

            public AsyncClient getAsyncClient(
                    org.apache.thrift.transport.TNonblockingTransport transport) {
                return new AsyncClient(protocolFactory, clientManager,
                        transport);
            }
        }

        public AsyncClient(
                org.apache.thrift.protocol.TProtocolFactory protocolFactory,
                org.apache.thrift.async.TAsyncClientManager clientManager,
                org.apache.thrift.transport.TNonblockingTransport transport) {
            super(protocolFactory, clientManager, transport);
        }

        public void getLocation(double lon, double lat,
                                AsyncMethodCallback resultHandler) throws TException {
            checkReady();
            getLocation_call method_call = new getLocation_call(lon, lat,
                    resultHandler, this, ___protocolFactory, ___transport);
            this.___currentMethod = method_call;
            ___manager.call(method_call);
        }

        public static class getLocation_call extends
                org.apache.thrift.async.TAsyncMethodCall {
            private double lon;
            private double lat;

            public getLocation_call(
                    double lon,
                    double lat,
                    AsyncMethodCallback resultHandler,
                    org.apache.thrift.async.TAsyncClient client,
                    org.apache.thrift.protocol.TProtocolFactory protocolFactory,
                    org.apache.thrift.transport.TNonblockingTransport transport)
                    throws TException {
                super(client, protocolFactory, transport, resultHandler, false);
                this.lon = lon;
                this.lat = lat;
            }

            public void write_args(org.apache.thrift.protocol.TProtocol prot)
                    throws TException {
                prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage(
                        "getLocation",
                        org.apache.thrift.protocol.TMessageType.CALL, 0));
                getLocation_args args = new getLocation_args();
                args.setLon(lon);
                args.setLat(lat);
                args.write(prot);
                prot.writeMessageEnd();
            }

            public MapLocation getResult() throws TException {
                if (getState() != State.RESPONSE_READ) {
                    throw new IllegalStateException("Method call not finished!");
                }
                org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(
                        getFrameBuffer().array());
                org.apache.thrift.protocol.TProtocol prot = client
                        .getProtocolFactory().getProtocol(memoryTransport);
                return (new Client(prot)).recv_getLocation();
            }
        }

    }

    public static class Processor<I extends Iface> extends
            org.apache.thrift.TBaseProcessor<I> implements
            org.apache.thrift.TProcessor {
        private static final Logger LOGGER = LoggerFactory
                .getLogger(Processor.class.getName());

        public Processor(I iface) {
            super(
                    iface,
                    getProcessMap(new HashMap<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>>()));
        }

        protected Processor(
                I iface,
                Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) {
            super(iface, getProcessMap(processMap));
        }

        private static <I extends Iface> Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> getProcessMap(
                Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) {
            processMap.put("getLocation", new getLocation());
            return processMap;
        }

        public static class getLocation<I extends Iface> extends
                org.apache.thrift.ProcessFunction<I, getLocation_args> {
            public getLocation() {
                super("getLocation");
            }

            public getLocation_args getEmptyArgsInstance() {
                return new getLocation_args();
            }

            protected boolean isOneway() {
                return false;
            }

            public getLocation_result getResult(I iface, getLocation_args args)
                    throws TException {
                getLocation_result result = new getLocation_result();
                result.success = iface.getLocation(args.lon, args.lat);
                return result;
            }
        }

    }

    public static class AsyncProcessor<I extends AsyncIface> extends
            org.apache.thrift.TBaseAsyncProcessor<I> {
        private static final Logger LOGGER = LoggerFactory
                .getLogger(AsyncProcessor.class.getName());

        public AsyncProcessor(I iface) {
            super(
                    iface,
                    getProcessMap(new HashMap<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>>()));
        }

        protected AsyncProcessor(
                I iface,
                Map<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>> processMap) {
            super(iface, getProcessMap(processMap));
        }

        private static <I extends AsyncIface> Map<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>> getProcessMap(
                Map<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>> processMap) {
            processMap.put("getLocation", new getLocation());
            return processMap;
        }

        public static class getLocation<I extends AsyncIface>
                extends
                org.apache.thrift.AsyncProcessFunction<I, getLocation_args, MapLocation> {
            public getLocation() {
                super("getLocation");
            }

            public getLocation_args getEmptyArgsInstance() {
                return new getLocation_args();
            }

            public AsyncMethodCallback<MapLocation> getResultHandler(
                    final AsyncFrameBuffer fb, final int seqid) {
                final org.apache.thrift.AsyncProcessFunction fcall = this;
                return new AsyncMethodCallback<MapLocation>() {
                    public void onComplete(MapLocation o) {
                        getLocation_result result = new getLocation_result();
                        result.success = o;
                        try {
                            fcall.sendResponse(
                                    fb,
                                    result,
                                    org.apache.thrift.protocol.TMessageType.REPLY,
                                    seqid);
                            return;
                        } catch (Exception e) {
                            LOGGER.error(
                                    "Exception writing to internal frame buffer",
                                    e);
                        }
                        fb.close();
                    }

                    public void onError(Exception e) {
                        byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
                        org.apache.thrift.TBase msg;
                        getLocation_result result = new getLocation_result();
                        {
                            msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
                            msg = (org.apache.thrift.TBase) new org.apache.thrift.TApplicationException(
                                    org.apache.thrift.TApplicationException.INTERNAL_ERROR,
                                    e.getMessage());
                        }
                        try {
                            fcall.sendResponse(fb, msg, msgType, seqid);
                            return;
                        } catch (Exception ex) {
                            LOGGER.error(
                                    "Exception writing to internal frame buffer",
                                    ex);
                        }
                        fb.close();
                    }
                };
            }

            protected boolean isOneway() {
                return false;
            }

            public void start(I iface, getLocation_args args,
                              AsyncMethodCallback<MapLocation> resultHandler)
                    throws TException {
                iface.getLocation(args.lon, args.lat, resultHandler);
            }
        }

    }

    public static class getLocation_args
            implements
            org.apache.thrift.TBase<getLocation_args, getLocation_args._Fields>,
            java.io.Serializable, Cloneable, Comparable<getLocation_args> {
        private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct(
                "getLocation_args");

        private static final org.apache.thrift.protocol.TField LON_FIELD_DESC = new org.apache.thrift.protocol.TField(
                "lon", org.apache.thrift.protocol.TType.DOUBLE, (short) 1);
        private static final org.apache.thrift.protocol.TField LAT_FIELD_DESC = new org.apache.thrift.protocol.TField(
                "lat", org.apache.thrift.protocol.TType.DOUBLE, (short) 2);

        private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
        static {
            schemes.put(StandardScheme.class,
                    new getLocation_argsStandardSchemeFactory());
            schemes.put(TupleScheme.class,
                    new getLocation_argsTupleSchemeFactory());
        }

        public double lon; // required
        public double lat; // required

        /**
         * The set of fields this struct contains, along with convenience
         * methods for finding and manipulating them.
         */
        public enum _Fields implements org.apache.thrift.TFieldIdEnum {
            LON((short) 1, "lon"), LAT((short) 2, "lat");

            private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

            static {
                for (_Fields field : EnumSet.allOf(_Fields.class)) {
                    byName.put(field.getFieldName(), field);
                }
            }

            /**
             * Find the _Fields constant that matches fieldId, or null if its
             * not found.
             */
            public static _Fields findByThriftId(int fieldId) {
                switch (fieldId) {
                    case 1: // LON
                        return LON;
                    case 2: // LAT
                        return LAT;
                    default:
                        return null;
                }
            }

            /**
             * Find the _Fields constant that matches fieldId, throwing an
             * exception if it is not found.
             */
            public static _Fields findByThriftIdOrThrow(int fieldId) {
                _Fields fields = findByThriftId(fieldId);
                if (fields == null)
                    throw new IllegalArgumentException("Field " + fieldId
                            + " doesn't exist!");
                return fields;
            }

            /**
             * Find the _Fields constant that matches name, or null if its not
             * found.
             */
            public static _Fields findByName(String name) {
                return byName.get(name);
            }

            private final short _thriftId;
            private final String _fieldName;

            _Fields(short thriftId, String fieldName) {
                _thriftId = thriftId;
                _fieldName = fieldName;
            }

            public short getThriftFieldId() {
                return _thriftId;
            }

            public String getFieldName() {
                return _fieldName;
            }
        }

        // isset id assignments
        private static final int __LON_ISSET_ID = 0;
        private static final int __LAT_ISSET_ID = 1;
        private byte __isset_bitfield = 0;
        public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
        static {
            Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(
                    _Fields.class);
            tmpMap.put(_Fields.LON,
                    new org.apache.thrift.meta_data.FieldMetaData("lon",
                            org.apache.thrift.TFieldRequirementType.DEFAULT,
                            new org.apache.thrift.meta_data.FieldValueMetaData(
                                    org.apache.thrift.protocol.TType.DOUBLE)));
            tmpMap.put(_Fields.LAT,
                    new org.apache.thrift.meta_data.FieldMetaData("lat",
                            org.apache.thrift.TFieldRequirementType.DEFAULT,
                            new org.apache.thrift.meta_data.FieldValueMetaData(
                                    org.apache.thrift.protocol.TType.DOUBLE)));
            metaDataMap = Collections.unmodifiableMap(tmpMap);
            org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(
                    getLocation_args.class, metaDataMap);
        }

        public getLocation_args() {
        }

        public getLocation_args(double lon, double lat) {
            this();
            this.lon = lon;
            setLonIsSet(true);
            this.lat = lat;
            setLatIsSet(true);
        }

        /**
         * Performs a deep copy on <i>other</i>.
         */
        public getLocation_args(getLocation_args other) {
            __isset_bitfield = other.__isset_bitfield;
            this.lon = other.lon;
            this.lat = other.lat;
        }

        public getLocation_args deepCopy() {
            return new getLocation_args(this);
        }

        public void clear() {
            setLonIsSet(false);
            this.lon = 0.0;
            setLatIsSet(false);
            this.lat = 0.0;
        }

        public double getLon() {
            return this.lon;
        }

        public getLocation_args setLon(double lon) {
            this.lon = lon;
            setLonIsSet(true);
            return this;
        }

        public void unsetLon() {
            __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield,
                    __LON_ISSET_ID);
        }

        /**
         * Returns true if field lon is set (has been assigned a value) and
         * false otherwise
         */
        public boolean isSetLon() {
            return EncodingUtils.testBit(__isset_bitfield, __LON_ISSET_ID);
        }

        public void setLonIsSet(boolean value) {
            __isset_bitfield = EncodingUtils.setBit(__isset_bitfield,
                    __LON_ISSET_ID, value);
        }

        public double getLat() {
            return this.lat;
        }

        public getLocation_args setLat(double lat) {
            this.lat = lat;
            setLatIsSet(true);
            return this;
        }

        public void unsetLat() {
            __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield,
                    __LAT_ISSET_ID);
        }

        /**
         * Returns true if field lat is set (has been assigned a value) and
         * false otherwise
         */
        public boolean isSetLat() {
            return EncodingUtils.testBit(__isset_bitfield, __LAT_ISSET_ID);
        }

        public void setLatIsSet(boolean value) {
            __isset_bitfield = EncodingUtils.setBit(__isset_bitfield,
                    __LAT_ISSET_ID, value);
        }

        public void setFieldValue(_Fields field, Object value) {
            switch (field) {
                case LON:
                    if (value == null) {
                        unsetLon();
                    } else {
                        setLon((Double) value);
                    }
                    break;

                case LAT:
                    if (value == null) {
                        unsetLat();
                    } else {
                        setLat((Double) value);
                    }
                    break;

            }
        }

        public Object getFieldValue(_Fields field) {
            switch (field) {
                case LON:
                    return Double.valueOf(getLon());

                case LAT:
                    return Double.valueOf(getLat());

            }
            throw new IllegalStateException();
        }

        /**
         * Returns true if field corresponding to fieldID is set (has been
         * assigned a value) and false otherwise
         */
        public boolean isSet(_Fields field) {
            if (field == null) {
                throw new IllegalArgumentException();
            }

            switch (field) {
                case LON:
                    return isSetLon();
                case LAT:
                    return isSetLat();
            }
            throw new IllegalStateException();
        }

        @Override
        public boolean equals(Object that) {
            if (that == null)
                return false;
            if (that instanceof getLocation_args)
                return this.equals((getLocation_args) that);
            return false;
        }

        public boolean equals(getLocation_args that) {
            if (that == null)
                return false;

            boolean this_present_lon = true;
            boolean that_present_lon = true;
            if (this_present_lon || that_present_lon) {
                if (!(this_present_lon && that_present_lon))
                    return false;
                if (this.lon != that.lon)
                    return false;
            }

            boolean this_present_lat = true;
            boolean that_present_lat = true;
            if (this_present_lat || that_present_lat) {
                if (!(this_present_lat && that_present_lat))
                    return false;
                if (this.lat != that.lat)
                    return false;
            }

            return true;
        }

        @Override
        public int hashCode() {
            List<Object> list = new ArrayList<Object>();

            boolean present_lon = true;
            list.add(present_lon);
            if (present_lon)
                list.add(lon);

            boolean present_lat = true;
            list.add(present_lat);
            if (present_lat)
                list.add(lat);

            return list.hashCode();
        }

        @Override
        public int compareTo(getLocation_args other) {
            if (!getClass().equals(other.getClass())) {
                return getClass().getName().compareTo(
                        other.getClass().getName());
            }

            int lastComparison = 0;

            lastComparison = Boolean.valueOf(isSetLon()).compareTo(
                    other.isSetLon());
            if (lastComparison != 0) {
                return lastComparison;
            }
            if (isSetLon()) {
                lastComparison = org.apache.thrift.TBaseHelper.compareTo(
                        this.lon, other.lon);
                if (lastComparison != 0) {
                    return lastComparison;
                }
            }
            lastComparison = Boolean.valueOf(isSetLat()).compareTo(
                    other.isSetLat());
            if (lastComparison != 0) {
                return lastComparison;
            }
            if (isSetLat()) {
                lastComparison = org.apache.thrift.TBaseHelper.compareTo(
                        this.lat, other.lat);
                if (lastComparison != 0) {
                    return lastComparison;
                }
            }
            return 0;
        }

        public _Fields fieldForId(int fieldId) {
            return _Fields.findByThriftId(fieldId);
        }

        public void read(org.apache.thrift.protocol.TProtocol iprot)
                throws TException {
            schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
        }

        public void write(org.apache.thrift.protocol.TProtocol oprot)
                throws TException {
            schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder("getLocation_args(");
            boolean first = true;

            sb.append("lon:");
            sb.append(this.lon);
            first = false;
            if (!first)
                sb.append(", ");
            sb.append("lat:");
            sb.append(this.lat);
            first = false;
            sb.append(")");
            return sb.toString();
        }

        public void validate() throws TException {
            // check for required fields
            // check for sub-struct validity
        }

        private void writeObject(java.io.ObjectOutputStream out)
                throws java.io.IOException {
            try {
                write(new org.apache.thrift.protocol.TCompactProtocol(
                        new org.apache.thrift.transport.TIOStreamTransport(out)));
            } catch (TException te) {
                throw new java.io.IOException(te.getMessage());
            }
        }

        private void readObject(java.io.ObjectInputStream in)
                throws java.io.IOException, ClassNotFoundException {
            try {
                // it doesn't seem like you should have to do this, but java
                // serialization is wacky, and doesn't call the default
                // constructor.
                __isset_bitfield = 0;
                read(new org.apache.thrift.protocol.TCompactProtocol(
                        new org.apache.thrift.transport.TIOStreamTransport(in)));
            } catch (TException te) {
                throw new java.io.IOException(te.getMessage());
            }
        }

        private static class getLocation_argsStandardSchemeFactory implements
                SchemeFactory {
            public getLocation_argsStandardScheme getScheme() {
                return new getLocation_argsStandardScheme();
            }
        }

        private static class getLocation_argsStandardScheme extends
                StandardScheme<getLocation_args> {

            public void read(org.apache.thrift.protocol.TProtocol iprot,
                             getLocation_args struct) throws TException {
                org.apache.thrift.protocol.TField schemeField;
                iprot.readStructBegin();
                while (true) {
                    schemeField = iprot.readFieldBegin();
                    if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
                        break;
                    }
                    switch (schemeField.id) {
                        case 1: // LON
                            if (schemeField.type == org.apache.thrift.protocol.TType.DOUBLE) {
                                struct.lon = iprot.readDouble();
                                struct.setLonIsSet(true);
                            } else {
                                org.apache.thrift.protocol.TProtocolUtil.skip(
                                        iprot, schemeField.type);
                            }
                            break;
                        case 2: // LAT
                            if (schemeField.type == org.apache.thrift.protocol.TType.DOUBLE) {
                                struct.lat = iprot.readDouble();
                                struct.setLatIsSet(true);
                            } else {
                                org.apache.thrift.protocol.TProtocolUtil.skip(
                                        iprot, schemeField.type);
                            }
                            break;
                        default:
                            org.apache.thrift.protocol.TProtocolUtil.skip(iprot,
                                    schemeField.type);
                    }
                    iprot.readFieldEnd();
                }
                iprot.readStructEnd();

                // check for required fields of primitive type, which can't be
                // checked in the validate method
                struct.validate();
            }

            public void write(org.apache.thrift.protocol.TProtocol oprot,
                              getLocation_args struct) throws TException {
                struct.validate();

                oprot.writeStructBegin(STRUCT_DESC);
                oprot.writeFieldBegin(LON_FIELD_DESC);
                oprot.writeDouble(struct.lon);
                oprot.writeFieldEnd();
                oprot.writeFieldBegin(LAT_FIELD_DESC);
                oprot.writeDouble(struct.lat);
                oprot.writeFieldEnd();
                oprot.writeFieldStop();
                oprot.writeStructEnd();
            }

        }

        private static class getLocation_argsTupleSchemeFactory implements
                SchemeFactory {
            public getLocation_argsTupleScheme getScheme() {
                return new getLocation_argsTupleScheme();
            }
        }

        private static class getLocation_argsTupleScheme extends
                TupleScheme<getLocation_args> {

            @Override
            public void write(org.apache.thrift.protocol.TProtocol prot,
                              getLocation_args struct) throws TException {
                TTupleProtocol oprot = (TTupleProtocol) prot;
                BitSet optionals = new BitSet();
                if (struct.isSetLon()) {
                    optionals.set(0);
                }
                if (struct.isSetLat()) {
                    optionals.set(1);
                }
                oprot.writeBitSet(optionals, 2);
                if (struct.isSetLon()) {
                    oprot.writeDouble(struct.lon);
                }
                if (struct.isSetLat()) {
                    oprot.writeDouble(struct.lat);
                }
            }

            @Override
            public void read(org.apache.thrift.protocol.TProtocol prot,
                             getLocation_args struct) throws TException {
                TTupleProtocol iprot = (TTupleProtocol) prot;
                BitSet incoming = iprot.readBitSet(2);
                if (incoming.get(0)) {
                    struct.lon = iprot.readDouble();
                    struct.setLonIsSet(true);
                }
                if (incoming.get(1)) {
                    struct.lat = iprot.readDouble();
                    struct.setLatIsSet(true);
                }
            }
        }

    }

    public static class getLocation_result
            implements
            org.apache.thrift.TBase<getLocation_result, getLocation_result._Fields>,
            java.io.Serializable, Cloneable, Comparable<getLocation_result> {
        private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct(
                "getLocation_result");

        private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField(
                "success", org.apache.thrift.protocol.TType.STRUCT, (short) 0);

        private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
        static {
            schemes.put(StandardScheme.class,
                    new getLocation_resultStandardSchemeFactory());
            schemes.put(TupleScheme.class,
                    new getLocation_resultTupleSchemeFactory());
        }

        public MapLocation success; // required

        /**
         * The set of fields this struct contains, along with convenience
         * methods for finding and manipulating them.
         */
        public enum _Fields implements org.apache.thrift.TFieldIdEnum {
            SUCCESS((short) 0, "success");

            private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

            static {
                for (_Fields field : EnumSet.allOf(_Fields.class)) {
                    byName.put(field.getFieldName(), field);
                }
            }

            /**
             * Find the _Fields constant that matches fieldId, or null if its
             * not found.
             */
            public static _Fields findByThriftId(int fieldId) {
                switch (fieldId) {
                    case 0: // SUCCESS
                        return SUCCESS;
                    default:
                        return null;
                }
            }

            /**
             * Find the _Fields constant that matches fieldId, throwing an
             * exception if it is not found.
             */
            public static _Fields findByThriftIdOrThrow(int fieldId) {
                _Fields fields = findByThriftId(fieldId);
                if (fields == null)
                    throw new IllegalArgumentException("Field " + fieldId
                            + " doesn't exist!");
                return fields;
            }

            /**
             * Find the _Fields constant that matches name, or null if its not
             * found.
             */
            public static _Fields findByName(String name) {
                return byName.get(name);
            }

            private final short _thriftId;
            private final String _fieldName;

            _Fields(short thriftId, String fieldName) {
                _thriftId = thriftId;
                _fieldName = fieldName;
            }

            public short getThriftFieldId() {
                return _thriftId;
            }

            public String getFieldName() {
                return _fieldName;
            }
        }

        // isset id assignments
        public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
        static {
            Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(
                    _Fields.class);
            tmpMap.put(_Fields.SUCCESS,
                    new org.apache.thrift.meta_data.FieldMetaData("success",
                            org.apache.thrift.TFieldRequirementType.DEFAULT,
                            new org.apache.thrift.meta_data.StructMetaData(
                                    org.apache.thrift.protocol.TType.STRUCT,
                                    MapLocation.class)));
            metaDataMap = Collections.unmodifiableMap(tmpMap);
            org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(
                    getLocation_result.class, metaDataMap);
        }

        public getLocation_result() {
        }

        public getLocation_result(MapLocation success) {
            this();
            this.success = success;
        }

        /**
         * Performs a deep copy on <i>other</i>.
         */
        public getLocation_result(getLocation_result other) {
            if (other.isSetSuccess()) {
                this.success = new MapLocation(other.success);
            }
        }

        public getLocation_result deepCopy() {
            return new getLocation_result(this);
        }

        public void clear() {
            this.success = null;
        }

        public MapLocation getSuccess() {
            return this.success;
        }

        public getLocation_result setSuccess(MapLocation success) {
            this.success = success;
            return this;
        }

        public void unsetSuccess() {
            this.success = null;
        }

        /**
         * Returns true if field success is set (has been assigned a value) and
         * false otherwise
         */
        public boolean isSetSuccess() {
            return this.success != null;
        }

        public void setSuccessIsSet(boolean value) {
            if (!value) {
                this.success = null;
            }
        }

        public void setFieldValue(_Fields field, Object value) {
            switch (field) {
                case SUCCESS:
                    if (value == null) {
                        unsetSuccess();
                    } else {
                        setSuccess((MapLocation) value);
                    }
                    break;

            }
        }

        public Object getFieldValue(_Fields field) {
            switch (field) {
                case SUCCESS:
                    return getSuccess();

            }
            throw new IllegalStateException();
        }

        /**
         * Returns true if field corresponding to fieldID is set (has been
         * assigned a value) and false otherwise
         */
        public boolean isSet(_Fields field) {
            if (field == null) {
                throw new IllegalArgumentException();
            }

            switch (field) {
                case SUCCESS:
                    return isSetSuccess();
            }
            throw new IllegalStateException();
        }

        @Override
        public boolean equals(Object that) {
            if (that == null)
                return false;
            if (that instanceof getLocation_result)
                return this.equals((getLocation_result) that);
            return false;
        }

        public boolean equals(getLocation_result that) {
            if (that == null)
                return false;

            boolean this_present_success = true && this.isSetSuccess();
            boolean that_present_success = true && that.isSetSuccess();
            if (this_present_success || that_present_success) {
                if (!(this_present_success && that_present_success))
                    return false;
                if (!this.success.equals(that.success))
                    return false;
            }

            return true;
        }

        @Override
        public int hashCode() {
            List<Object> list = new ArrayList<Object>();

            boolean present_success = true && (isSetSuccess());
            list.add(present_success);
            if (present_success)
                list.add(success);

            return list.hashCode();
        }

        @Override
        public int compareTo(getLocation_result other) {
            if (!getClass().equals(other.getClass())) {
                return getClass().getName().compareTo(
                        other.getClass().getName());
            }

            int lastComparison = 0;

            lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(
                    other.isSetSuccess());
            if (lastComparison != 0) {
                return lastComparison;
            }
            if (isSetSuccess()) {
                lastComparison = org.apache.thrift.TBaseHelper.compareTo(
                        this.success, other.success);
                if (lastComparison != 0) {
                    return lastComparison;
                }
            }
            return 0;
        }

        public _Fields fieldForId(int fieldId) {
            return _Fields.findByThriftId(fieldId);
        }

        public void read(org.apache.thrift.protocol.TProtocol iprot)
                throws TException {
            schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
        }

        public void write(org.apache.thrift.protocol.TProtocol oprot)
                throws TException {
            schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder("getLocation_result(");
            boolean first = true;

            sb.append("success:");
            if (this.success == null) {
                sb.append("null");
            } else {
                sb.append(this.success);
            }
            first = false;
            sb.append(")");
            return sb.toString();
        }

        public void validate() throws TException {
            // check for required fields
            // check for sub-struct validity
            if (success != null) {
                success.validate();
            }
        }

        private void writeObject(java.io.ObjectOutputStream out)
                throws java.io.IOException {
            try {
                write(new org.apache.thrift.protocol.TCompactProtocol(
                        new org.apache.thrift.transport.TIOStreamTransport(out)));
            } catch (TException te) {
                throw new java.io.IOException(te.getMessage());
            }
        }

        private void readObject(java.io.ObjectInputStream in)
                throws java.io.IOException, ClassNotFoundException {
            try {
                read(new org.apache.thrift.protocol.TCompactProtocol(
                        new org.apache.thrift.transport.TIOStreamTransport(in)));
            } catch (TException te) {
                throw new java.io.IOException(te.getMessage());
            }
        }

        private static class getLocation_resultStandardSchemeFactory implements
                SchemeFactory {
            public getLocation_resultStandardScheme getScheme() {
                return new getLocation_resultStandardScheme();
            }
        }

        private static class getLocation_resultStandardScheme extends
                StandardScheme<getLocation_result> {

            public void read(org.apache.thrift.protocol.TProtocol iprot,
                             getLocation_result struct) throws TException {
                org.apache.thrift.protocol.TField schemeField;
                iprot.readStructBegin();
                while (true) {
                    schemeField = iprot.readFieldBegin();
                    if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
                        break;
                    }
                    switch (schemeField.id) {
                        case 0: // SUCCESS
                            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
                                struct.success = new MapLocation();
                                struct.success.read(iprot);
                                struct.setSuccessIsSet(true);
                            } else {
                                org.apache.thrift.protocol.TProtocolUtil.skip(
                                        iprot, schemeField.type);
                            }
                            break;
                        default:
                            org.apache.thrift.protocol.TProtocolUtil.skip(iprot,
                                    schemeField.type);
                    }
                    iprot.readFieldEnd();
                }
                iprot.readStructEnd();

                // check for required fields of primitive type, which can't be
                // checked in the validate method
                struct.validate();
            }

            public void write(org.apache.thrift.protocol.TProtocol oprot,
                              getLocation_result struct) throws TException {
                struct.validate();

                oprot.writeStructBegin(STRUCT_DESC);
                if (struct.success != null) {
                    oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
                    struct.success.write(oprot);
                    oprot.writeFieldEnd();
                }
                oprot.writeFieldStop();
                oprot.writeStructEnd();
            }

        }

        private static class getLocation_resultTupleSchemeFactory implements
                SchemeFactory {
            public getLocation_resultTupleScheme getScheme() {
                return new getLocation_resultTupleScheme();
            }
        }

        private static class getLocation_resultTupleScheme extends
                TupleScheme<getLocation_result> {

            @Override
            public void write(org.apache.thrift.protocol.TProtocol prot,
                              getLocation_result struct) throws TException {
                TTupleProtocol oprot = (TTupleProtocol) prot;
                BitSet optionals = new BitSet();
                if (struct.isSetSuccess()) {
                    optionals.set(0);
                }
                oprot.writeBitSet(optionals, 1);
                if (struct.isSetSuccess()) {
                    struct.success.write(oprot);
                }
            }

            @Override
            public void read(org.apache.thrift.protocol.TProtocol prot,
                             getLocation_result struct) throws TException {
                TTupleProtocol iprot = (TTupleProtocol) prot;
                BitSet incoming = iprot.readBitSet(1);
                if (incoming.get(0)) {
                    struct.success = new MapLocation();
                    struct.success.read(iprot);
                    struct.setSuccessIsSet(true);
                }
            }
        }

    }

}

